<template>
	<view class="container">
		<u--form ref="queryForm" :model="query">
			<u-form-item label="料架码" prop="rackCode" labelWidth="120rpx">
				<u--input 
					placeholder="请输入/扫描" 
					v-model="query.rackCode" 
					suffixIcon="scan" 
					suffixIconStyle="font-size: 68rpx"
					style="flex: 1;"
				>
				</u--input>
			</u-form-item>
		</u--form>
		<!-- 提示组件 -->
		<u-toast ref="uToast"></u-toast>
		<view class="commonButton">
			<u-button type="primary" @click="submit">确认</u-button>
		</view>
	</view>
</template>

<script>
	import { scanMaterialAPI } from '@/api/work/other'
	export default {
		data() {
			return {
				query: {
					rackCode: ''
				}
			};
		},
		methods: {
			async submit() {
				if (!this.query.rackCode) {
					return this.$refs.uToast.show({
						type: 'warning',
						message: '请扫描料架码'
					})
				}
				const submitForm = {
					rackCode: this.query.rackCode
				}
				const res = await scanMaterialAPI(submitForm)
				if (res.code === 200) {
					this.$refs.uToast.show({
						type: 'success',
						message: res.message
					})
					this.query = {
						rackCode: ''
					}
				} else {
					return this.$refs.uToast.show({
						type: 'warning',
						message: res.message
					})
				}
			}
		}
	}
</script>

<style lang="scss">
.commonButton {
	width: 100%;
	display: flex;
	gap: 20rpx;
	position: fixed;
	left: 0;
	bottom: 0;
	box-sizing: border-box;
	padding: 15rpx;
	justify-content: space-between;
}
</style>
